package org.example.types.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 数据来源类型枚举
 */
@Getter
@AllArgsConstructor
public enum SourceType {

    ALL("all", "全部来源"),
    TG("tg", "仅Telegram"),
    PLUGIN("plugin", "仅插件");

    private final String code;
    private final String name;

    /**
     * 根据代码获取枚举
     */
    public static SourceType fromCode(String code) {
        for (SourceType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return ALL;
    }
}